library(dplyr)
library(readr)
library(ggplot2)
library(openxlsx)
library(knitr)
library(tibble)
library(stringr)
library(stringi)
library(readxl)
library(lubridate)
library(shiny)
library(plotly)

1 Loading the Data and Removal of Training Data

# Unzip and extract ODK data from ODK zip
df <- as.data.frame(extract_data_from_odk_zip(params$file_path_zip, params$file_name_csv))

# Formatting dates from integer (in ms) to time stamp
df$start <- format_date_ms(df$start)
df$end <- format_date_ms(df$end)

# filtering for events that occurred after 18th July 21
df <- subset(df, as.Date(start) > as.Date("18.07.2021", "%d.%m.%Y"))

2 Deriving New Features

2.1 Time Spent per Event

# subtracting end from start date
df$time_spent = round(as.numeric(df$end - df$start))

2.2 Question

# splitting the node strings so that only the question name remains 
df$question = sapply(df$node, create_question)

2.3 Question Decoded

df <- decode_question(df, df$question, params$codebook)

2.4 Categorical Answers Decoded

df <- decode_categories(df, params$codebook)

2.5 Time until a Response was Changed + Stream of Answer Changes

df <- df %>%
# bringing the data in the right order   
  arrange(`instance ID`, node, start) %>%
# adding two empty columns to store the new features in
  add_column(time_till_change=NA) %>%
  add_column(changed_from=NA)

# iterating over the df and computing the time it took until an answer was changed + adding what the question was before 
for (i in 1:nrow(df)){
  if (df$`old-value`[i]==df$`new-value`[i-1] && !is.na(df$`old-value`[i]) && !is.na(df$`new-value`[i-1]) ){
    df$time_till_change[i] <- round(as.numeric(df$start[i]-df$end[i-1]))
  } else{
    next
  }
}

2.6 Preview and Summary of the Final Data

head(df)
instance ID event node start end latitude longitude accuracy old-value new-value time_spent question question_decoded new_value_decoded old_value_decoded time_till_change changed_from
uuid:0007c684-8cc6-4e5a-b0f2-cb67192a8a66 group questions /data/a1 2021-09-10 11:23:46 2021-09-10 11:23:53 NA NA NA NA NA 8 a1 NA NA NA NA NA
uuid:0007c684-8cc6-4e5a-b0f2-cb67192a8a66 question /data/a1/a1_a_4 2021-09-10 11:23:46 2021-09-10 11:23:53 NA NA NA NA T-F0041-P0107 8 a1_a_4 Please scan the participant’s QR code T-F0041-P0107 NA NA NA
uuid:0007c684-8cc6-4e5a-b0f2-cb67192a8a66 group questions /data/b1 2021-09-10 11:23:44 2021-09-10 11:23:46 NA NA NA NA NA 2 b1 NA NA NA NA NA
uuid:0007c684-8cc6-4e5a-b0f2-cb67192a8a66 group questions /data/b2 2021-09-10 11:24:39 2021-09-10 11:24:49 NA NA NA NA NA 10 b2 NA NA NA NA NA
uuid:0007c684-8cc6-4e5a-b0f2-cb67192a8a66 question /data/b2/b1_7 2021-09-10 11:24:39 2021-09-10 11:24:49 NA NA NA NA 1 10 b1_7 Is this facility the closest health facility to your home? Yes NA NA NA
uuid:0007c684-8cc6-4e5a-b0f2-cb67192a8a66 question /data/b2/b2_10 2021-09-10 11:24:39 2021-09-10 11:24:49 NA NA NA NA 1 10 b2_10 Did you miss work to bring the child to the facility today? Yes NA NA NA
summary(df)
##  instance ID           event               node          
##  Length:25996       Length:25996       Length:25996      
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##                                                          
##                                                          
##                                                          
##                                                          
##      start                          end                      latitude      
##  Min.   :2021-07-19 10:10:14   Min.   :2021-07-19 10:10:17   Mode:logical  
##  1st Qu.:2021-08-24 10:53:47   1st Qu.:2021-08-24 10:55:37   NA's:25996    
##  Median :2021-09-06 12:55:32   Median :2021-09-06 12:53:14                 
##  Mean   :2021-08-29 08:40:13   Mean   :2021-08-29 09:18:03                 
##  3rd Qu.:2021-09-13 08:45:46   3rd Qu.:2021-09-13 09:10:01                 
##  Max.   :2021-09-17 12:13:32   Max.   :2021-09-17 12:13:32                 
##                                NA's   :3502                                
##  longitude      accuracy        old-value          new-value        
##  Mode:logical   Mode:logical   Length:25996       Length:25996      
##  NA's:25996     NA's:25996     Class :character   Class :character  
##                                Mode  :character   Mode  :character  
##                                                                     
##                                                                     
##                                                                     
##                                                                     
##    time_spent        question         question_decoded   new_value_decoded 
##  Min.   :   0.00   Length:25996       Length:25996       Length:25996      
##  1st Qu.:   5.00   Class :character   Class :character   Class :character  
##  Median :  12.00   Mode  :character   Mode  :character   Mode  :character  
##  Mean   :  25.95                                                           
##  3rd Qu.:  28.00                                                           
##  Max.   :9537.00                                                           
##  NA's   :3502                                                              
##  old_value_decoded  time_till_change changed_from  
##  Length:25996       Min.   : 1.00    Mode:logical  
##  Class :character   1st Qu.: 2.00    NA's:25996    
##  Mode  :character   Median : 4.00                  
##                     Mean   :10.68                  
##                     3rd Qu.:10.00                  
##                     Max.   :55.00                  
##                     NA's   :25845

3 General Information about the Data

no_inst = length(unique(df$`instance ID`))
no_event =  nrow(df)
earliest_start = as.Date(min(df$start)) 
latest_end = as.Date(max(df$end[!is.na(df$end)]))

Total number of instances: 605
Total number of events/questions: 25996
Examination period: 2021-07-19 - 2021-09-17

4 Grouped by Time

4.1 Events/Questions Started by Day

df_by_day <- df %>%
  mutate(start_date = as.Date(start)) %>%
  count(start_date, name = "count")

gg1 <- ggplot(df_by_day, aes(x = start_date, y = count)) +
  geom_line() +
  geom_smooth(alpha=0.5, colour="red", method="loess", se=F) +
  labs(title = "Number of Events/Questions Started by Day with Smoothed Regression Line", y =  "Number of Questions/Events Started", x = "Satrt Date") +
  theme_light() 
gg1

4.2 Questions/Events started by Weekday and Hour of the Day

df_wday_hour <- df %>%
  mutate(wday=wday(start, label=T, week_start = 1), hour=hour(start)) %>%
  count(wday, hour, name="count_wday_hour") %>%
  arrange(desc(wday))

theme_heatmap <- theme_light() +                 
  theme(panel.grid = element_blank(),            
        panel.border = element_blank(),          
        plot.title = element_text(face = "bold", size = 11, hjust = 0.5), 
        axis.ticks = element_blank(),            
        axis.title.x = element_blank(),        
        axis.title.y = element_text(size=10),   
        axis.text.y = element_text(size = 8),    
        axis.text.x = element_text(size = 10),   
        legend.position = "none")                

gg2 <- ggplot(df_wday_hour, aes(x = wday, y = hour, fill = count_wday_hour)) +
  geom_tile(colour="white") +  
  scale_fill_gradient(low = "#fff0f0", high="#940606") +  
  scale_y_reverse(breaks=c(23:0), labels=c(23:0), expand = c(0,0)) +               
  scale_x_discrete(expand = c(0,0), position = "top") +
  labs(title = "Number of Started Events/Questions by Day of Week / Hour of Day", y = "Hour of Day") +
  geom_text(aes(label = count_wday_hour), size = 2) +
  theme_heatmap  
gg2

4.3 Distribution of Time Spent per Event/Question with largest 5 % removed

df_clean = subset(df, time_spent<quantile(df$time_spent,0.95, na.rm=TRUE))

hist(df_clean$time_spent[!is.na(df_clean$time_spent)]/60, breaks=20, xlab = "Time Spent in Minutes", main = "Histogram of the Time Spent by Question")

5 Aggregated by Event/Question

5.1 Median Time Spent by Question

df_median_time_per_question <- df %>%
  filter(event=="question") %>%
  group_by(question_decoded) %>%
  summarise(median_time_spent = median(time_spent)) %>%
  arrange(desc(median_time_spent)) %>%
  mutate(median_time_spent = round(seconds_to_period(median_time_spent)))

df_median_time_per_question
question_decoded median_time_spent
Were you given a paper or record to take with you for completing the referral? 2M 9S
What is the main reason for you to choose coming here today rather than going to the closest facility? 1M 16S
Were you told why to go? 1M 0S
What do you intend to do now? 1M 0S
When do you need to complete the referral? 1M 0S
Were you told where to go? 51S
Can you specify these signs and symptoms? 37S
Did the provider speak in a language you understand? 25S
Did you feel the provider treated you and the child with respect? 25S
Did you find the provider showed concern and empathy? 25S
Did you find the provider was kind to you? 25S
How do you feel overall with the service you received at the facility today? 25S
If QR code scanning is not possible, please manually enter the participant identification code 25S
Was the service delayed or were you kept waiting for a long time? 25S
Would you recommend this facility to a friend / family with a sick child? 25S
Did you miss work to bring the child to the facility today? 24S
Did you pay for something at the facility today? 24S
Do you intend to buy some medicines outside of the facility? 24S
Is this facility the closest health facility to your home? 24S
Were you informed of signs / symptoms that require you to bring the child back to the facility immediately? 19S
What do you intend to do if the sick child does not get completely better or become worse? 18S
Were you given general information or advice about feeding or breastfeeding? 18S
Can you show me all the medicines and prescriptions that you received? 17S
How did you feel with the fact that the provider used of a tablet for the consultation of the child? 16S
Where will you look for treatment? 15S
Did the provider explain to you the result that was given by the device? 14S
Can you explain to me why this device was used? 14S
Please specify ‘Other’. 14S
Please scan the participant’s QR code 13S
Please select the current district 12S
Did the provider explain to you how to give these medicines to the child at home? 11S
How confident do you feel in how much of the medication to give each day and how many days to give it? 11S
Who will you ask for advice? 11S
Did the provider give or prescribe any medicines for the child to take home? 9S
Did the provider refer the child? 9S
Did the provider tell you what illness your child has? 9S
fcode 8S
How many work days did you miss as the result of this visit? 6S
Did the provider use the device that is represented in the following picture during the consultation of the child? 4S
Did the provider use a tablet like this one for the consultation of the child? 3S

5.2 Count of Input Changes and Median Time until Input was Changed by Question

df_changes_per_question <- df %>%
  filter(event=="question", 
         !is.na(time_till_change)) %>%
  group_by(question_decoded) %>%
  summarise(count_input_changes=n(), 
            median_time_till_change=median(time_till_change), 
            sd_time_till_change=sd(time_till_change)) %>%
  arrange(desc(count_input_changes)) %>%
  mutate(median_time_till_change = round(seconds_to_period(median_time_till_change)),
         sd_time_till_change = round(seconds_to_period(sd_time_till_change), 1)) %>%
  filter(count_input_changes > 1)

df_changes_per_question
question_decoded count_input_changes median_time_till_change sd_time_till_change
Did the provider explain to you how to give these medicines to the child at home? 29 3S 15.4S
How confident do you feel in how much of the medication to give each day and how many days to give it? 18 4S 16.2S
Do you intend to buy some medicines outside of the facility? 12 6S 13.3S
If QR code scanning is not possible, please manually enter the participant identification code 11 3S 20.7S
How do you feel overall with the service you received at the facility today? 10 6S 16S
Did the provider tell you what illness your child has? 7 5S 3.5S
Were you informed of signs / symptoms that require you to bring the child back to the facility immediately? 6 10S 18.3S
What do you intend to do if the sick child does not get completely better or become worse? 6 3S 21S
Did you miss work to bring the child to the facility today? 5 2S 17.8S
Was the service delayed or were you kept waiting for a long time? 5 2S 4.1S
Did you find the provider showed concern and empathy? 4 10S 18.9S
Please scan the participant’s QR code 4 3S 2.6S
Were you given general information or advice about feeding or breastfeeding? 4 2S 2.2S
Would you recommend this facility to a friend / family with a sick child? 4 12S 15S
Did the provider refer the child? 3 3S 12.7S
Did the provider use the device that is represented in the following picture during the consultation of the child? 3 4S 2.1S
Did you feel the provider treated you and the child with respect? 3 7S 8.7S
Did you find the provider was kind to you? 3 19S 24.4S
Did you pay for something at the facility today? 3 2S 0.6S
Is this facility the closest health facility to your home? 3 6S 3.2S
Can you show me all the medicines and prescriptions that you received? 2 24S 31.8S
Did the provider give or prescribe any medicines for the child to take home? 2 3S 1.4S

5.3 Count of Old-New Value Pairs

df_stream <- df %>%
  filter(!is.na(time_till_change)) %>%
  count(question_decoded, 
        old_value_decoded, 
        new_value_decoded, 
        name="count_value_pairs", 
        sort=TRUE) %>%
  filter(count_value_pairs > 1)

df_stream
question_decoded old_value_decoded new_value_decoded count_value_pairs
Did the provider explain to you how to give these medicines to the child at home? Yes, for all medicines Yes, but only for some medicines 8
Did the provider explain to you how to give these medicines to the child at home? Yes, but only for some medicines Yes, for all medicines 6
Did the provider explain to you how to give these medicines to the child at home? No Yes, but only for some medicines 5
Did the provider tell you what illness your child has? No Yes 5
Do you intend to buy some medicines outside of the facility? No Yes, prescribed by the healthcare provider but not available at the facility 5
Did the provider explain to you how to give these medicines to the child at home? Yes, but only for some medicines No 4
Did you miss work to bring the child to the facility today? No Yes 4
How do you feel overall with the service you received at the facility today? Very satisfied Somewhat satisfied 4
Did the provider explain to you how to give these medicines to the child at home? No Yes, for all medicines 3
Do you intend to buy some medicines outside of the facility? Yes, prescribed by the healthcare provider but not available at the facility No 3
How confident do you feel in how much of the medication to give each day and how many days to give it? Not confident at all Neutral 3
How confident do you feel in how much of the medication to give each day and how many days to give it? Very confident Not confident at all 3
How do you feel overall with the service you received at the facility today? Somewhat satisfied Very satisfied 3
Were you given general information or advice about feeding or breastfeeding? None of the above Guidance on feeding 3
Were you informed of signs / symptoms that require you to bring the child back to the facility immediately? No Yes 3
Did the provider explain to you how to give these medicines to the child at home? Yes, for all medicines No 2
Did the provider give or prescribe any medicines for the child to take home? Yes No 2
Did the provider refer the child? Yes No 2
Did you feel the provider treated you and the child with respect? Agree Strongly agree 2
Did you find the provider showed concern and empathy? Agree Strongly agree 2
How confident do you feel in how much of the medication to give each day and how many days to give it? Neutral Quite confident 2
How confident do you feel in how much of the medication to give each day and how many days to give it? Very confident Quite confident 2
Is this facility the closest health facility to your home? Yes No, closest facility is also public 2
Was the service delayed or were you kept waiting for a long time? Strongly agree Neither agree nor disagree 2
Were you informed of signs / symptoms that require you to bring the child back to the facility immediately? Yes No 2
What do you intend to do if the sick child does not get completely better or become worse? Return to this facility Not sure 2
Would you recommend this facility to a friend / family with a sick child? Strongly agree Agree 2

6 Aggregated by Instance

6.1 Top 10 % of Duration by Instance

df_duration_per_inst <- df %>%
  group_by(`instance ID`) %>%
  summarise(duration_per_inst = max(end, na.rm=T) - min(start, na.rm=T)) %>% 
  filter(duration_per_inst>quantile(duration_per_inst, 0.9, na.rm=TRUE)) %>%
  mutate(duration_per_inst = round(seconds_to_period(duration_per_inst))) %>%
  arrange(desc(duration_per_inst))

df_duration_per_inst
instance ID duration_per_inst
uuid:50e579ce-3dde-43f0-9aec-d524233cfcb0 13d 8H 41M 3S
uuid:cc442175-3aa6-4243-b00d-e672a0585178 23H 15M 53S
uuid:fe19d5c8-1133-4a84-ba9f-92c297706c26 22H 53M 8S
uuid:4c2f4e8c-7123-4990-aa87-3d678ff428cc 21H 49M 28S
uuid:e7574a4b-ff0b-4b2f-9942-9f4282524a99 10H 56M 26S
uuid:04062787-e431-47f3-a276-7e7449c1ba31 10H 41M 35S
uuid:e7b710f5-009f-4c2a-9844-5755892fd15f 10H 13M 53S
uuid:894e09b4-b086-4f3d-b5ad-9b37c3d7db5e 10H 3M 3S
uuid:22836c00-cfca-40f4-b93c-016f38b39f2f 9H 54M 15S
uuid:5d8c5ed1-38a4-4f61-af34-c91790768807 9H 28M 30S
uuid:779cbe18-561e-4193-ba35-9a4af5fd2542 9H 23M 43S
uuid:e6c374ba-9eba-43f8-886e-64970a4199ef 9H 20M 49S
uuid:90b6756a-b478-47d5-8b5c-66f10b5cb41e 9H 18M 38S
uuid:99b5b7c4-181d-47ae-8c7f-e1bbdef04fe1 9H 13M 55S
uuid:dbf06342-e53e-47f7-8c34-7ffb9d67a148 9H 5M 60S
uuid:6b7f2d0a-c7f8-4b4d-9ef0-be0f370d96fd 9H 1M 21S
uuid:28a13d6d-da44-4f5a-a23c-7706b20112be 8H 59M 9S
uuid:8391f8ad-0967-4297-8e8a-6c9fec26a5b1 8H 56M 35S
uuid:a5d903fb-bd9c-42b1-a403-89232e57ec58 8H 54M 32S
uuid:9ac93673-a115-4950-a011-fbfc187c43ea 8H 50M 43S
uuid:8585b51e-a288-4125-a062-524d72d6c465 8H 37M 28S
uuid:40f92c1d-733b-40a5-a7f7-52bc2909b075 8H 35M 49S
uuid:d7a96c16-ed12-4f1e-945f-422822d46194 8H 31M 4S
uuid:fef45a05-7161-4d88-acfb-620a954e33e7 8H 29M 39S
uuid:a8be70f0-dd30-4183-a4c8-2dbeccb1de93 8H 25M 23S
uuid:071e2190-c784-46e8-aa66-0afb95eea292 8H 22M 32S
uuid:4545b695-ca97-44ff-adfe-9604806781f8 8H 19M 46S
uuid:37c2ef80-5ed7-41df-add3-0f6383af770d 8H 16M 11S
uuid:b2f88174-fa94-4eae-98da-fa9b3b54fbc4 8H 15M 55S
uuid:2e6bb90d-c464-4966-9d3b-398cd01930ee 8H 15M 50S
uuid:cd4d093f-3b29-4071-a9d8-6786177cd74f 8H 11M 6S
uuid:e5357bf4-4079-4b2c-940a-7b7521dacf82 8H 10M 57S
uuid:5adf39c1-5d80-4d04-9853-1833f9f1db0a 8H 6M 11S
uuid:86b36993-0e4a-4778-9a5a-a046cc4cf1f9 8H 5M 43S
uuid:47428561-8e97-42a4-8153-fae672011d6a 8H 4M 18S
uuid:4446cb0b-12db-46b8-b7f0-eeba2ce630a4 8H 3M 33S
uuid:56067d5b-2912-4cdd-b451-767d64eb35b1 7H 56M 15S
uuid:c56cc981-531a-4b15-889e-f935b0bc6853 7H 47M 1S
uuid:51be9539-cb94-49ec-81f8-92ae1800d0e8 7H 46M 32S
uuid:f4b56869-7d40-4343-b5d3-33bcbac3d383 7H 42M 56S
uuid:bc73c822-d152-4da7-bdc6-f535baf1c902 7H 41M 7S
uuid:9da2333c-6ff3-4f6d-9f86-b8438195bc73 7H 33M 26S
uuid:b44f6d99-f5a9-4f27-b012-034e968844f9 7H 33M 8S
uuid:f719e462-8c88-43bb-aa67-665a8eec4f83 7H 29M 55S
uuid:2a62691a-3990-4a67-acab-8a1e71cc9d0a 7H 26M 11S
uuid:3925c614-1e56-402a-9f90-cb0775515eac 7H 24M 51S
uuid:2d6a3f65-96ed-4dbd-8fc0-980b7eaf36b4 7H 17M 51S
uuid:4811648f-5674-4bc0-a230-fb8a5306389e 7H 7M 1S
uuid:734dd702-cd51-4fd9-8e7e-178bf17ee577 7H 4M 46S
uuid:b86b9b2a-7920-47e4-8008-05e6f3b2fd72 6H 58M 55S
uuid:36213f71-2bcc-4ccb-9d1c-615b2eeaeca5 6H 57M 29S
uuid:72fcd75c-766e-4f97-84bb-5ee7fb345a60 6H 50M 23S
uuid:a0c3266b-be53-487c-95c8-a095b0fd3a33 6H 47M 59S
uuid:26294034-3cf6-4895-9c2c-a6780f5f51e4 6H 41M 32S
uuid:a4dce616-df8c-4446-81df-972900b8b241 6H 32M 4S
uuid:199020c5-9e27-404c-b21c-d2b43de67321 6H 20M 47S
uuid:8fde321c-00df-46a0-96b4-98f4188a997a 6H 17M 36S
uuid:7d93d6d1-088a-4f4b-a7e6-6907e7196f9d 6H 11M 52S
uuid:cce06f6f-ccd4-43e1-94c1-a1668d713c22 6H 6M 53S
uuid:3b2848bc-1fba-4ce7-882e-d5c6e455b850 6H 5M 31S
uuid:50747fec-7fb3-4d1d-81e0-259ee646625e 5H 51M 51S

6.2 Distribution of Duration by Instance with Top 10 % excluded

df_subsetted <- df %>%
  group_by(`instance ID`) %>%
  summarise(duration_per_inst = max(end, na.rm=T) - min(start, na.rm=T)) %>%
  filter(duration_per_inst<quantile(duration_per_inst, 0.9, na.rm=TRUE))
 
hist(as.numeric(df_subsetted$duration_per_inst/60), breaks=30, main="Duration per Instance in Minutes (outliers removed)", xlab="Duration in Minutes")

7 Irregularities and Outliers

7.1 Time Till Change Outliers (for all data without removed outliers)

df_time_till_change_outliers <- df %>% 
  filter(time_till_change>quantile(df$time_till_change, 0.9, na.rm=TRUE)) %>% 
  arrange(desc(time_till_change)) %>%
  mutate(time_till_change = round(seconds_to_period(time_till_change))) %>%
  select(`instance ID`, 
         question_decoded, 
         old_value_decoded, 
         new_value_decoded, 
         time_till_change)

df_time_till_change_outliers
instance ID question_decoded old_value_decoded new_value_decoded time_till_change
uuid:93cad7f3-b38d-4574-8f62-92b39545ad35 If QR code scanning is not possible, please manually enter the participant identification code T-F0102-P0105 T-F0102-P0136 55S
uuid:9abf7a26-9060-43de-a344-bad7ae1ecb1c What do you intend to do if the sick child does not get completely better or become worse? Return to this facility Not sure 54S
uuid:a7cde547-29d1-44e3-aa4f-a23073287462 How do you feel overall with the service you received at the facility today? Very satisfied Somewhat satisfied 54S
uuid:a7cde547-29d1-44e3-aa4f-a23073287462 Did you find the provider was kind to you? Agree Strongly agree 54S
uuid:ff4ea200-cfba-4839-bd33-a2781ef87748 If QR code scanning is not possible, please manually enter the participant identification code T-F0102-P0145 T-F0102-P0087 53S
uuid:ff4ea200-cfba-4839-bd33-a2781ef87748 Did the provider explain to you how to give these medicines to the child at home? Yes, but only for some medicines No 53S
uuid:ff4ea200-cfba-4839-bd33-a2781ef87748 How confident do you feel in how much of the medication to give each day and how many days to give it? Very confident Quite confident 53S
uuid:46717996-f9dd-403b-9f85-2e519d1b0939 Can you show me all the medicines and prescriptions that you received? Prescriptions only, no medicines Some medicines and some unfilled prescriptions 46S
uuid:46717996-f9dd-403b-9f85-2e519d1b0939 Did the provider explain to you how to give these medicines to the child at home? No Yes, but only for some medicines 46S
uuid:46717996-f9dd-403b-9f85-2e519d1b0939 How confident do you feel in how much of the medication to give each day and how many days to give it? Neutral Very confident 46S
uuid:46717996-f9dd-403b-9f85-2e519d1b0939 Were you informed of signs / symptoms that require you to bring the child back to the facility immediately? Yes No 46S
uuid:1243919f-9670-4a1b-a770-41ba0233ec0f Did you miss work to bring the child to the facility today? No Yes 42S
uuid:808f3baa-6c4f-4a9f-8989-c7f6ae16b9fd Did you find the provider showed concern and empathy? Agree Strongly agree 42S
uuid:fd14f141-3196-4946-8e09-a4dffc19a138 Did the provider explain to you how to give these medicines to the child at home? Yes, for all medicines Declined 42S
uuid:808f3baa-6c4f-4a9f-8989-c7f6ae16b9fd Do you intend to buy some medicines outside of the facility? Yes, prescribed by the healthcare provider but not available at the facility Yes, in addition to the medicines prescribed by the healthcare provider 41S

7.2 Histograms of Instances with Inconsistent Filling Behaviour

irregular_inst = c()
for (id in unique(df$`instance ID`)){
  bin_vec = cut(df$start[df$`instance ID`==id], 
                breaks=10, 
                labels=F)
  if (length(unique(bin_vec)) < 5) irregular_inst = c(irregular_inst, id)
}
paste0(length(irregular_inst), " out of ", length(unique(df$`instance ID`))," instances were found to have an inconsistent filling behaviour.")
## [1] "283 out of 605 instances were found to have an inconsistent filling behaviour."
last_bin_questions = c()
fig <- plot_ly(alpha=0.1)
for (id in irregular_inst){
  temp_df = df[df$`instance ID`==id,]
  temp_df$cut = cut(temp_df$start, breaks=10, labels=c("1. Part", "2. Part", "3. Part", "4. Part", "5. Part", "6. Part", "7. Part", "8. Part", "9. Part", "10. Part"))
  fig <- fig %>% add_histogram(x=temp_df$cut, name=id)
  
  last_bin_questions = c(last_bin_questions, temp_df$question_decoded[temp_df$cut=="10. Part"])
}
fig <- fig %>% layout(barmode = "overlay")
fig
kable(table(last_bin_questions) %>% as.data.frame() %>% arrange(desc(Freq)))
last_bin_questions Freq
Do you intend to buy some medicines outside of the facility? 21
Did you miss work to bring the child to the facility today? 16
Did you pay for something at the facility today? 16
Is this facility the closest health facility to your home? 15
Did the provider explain to you how to give these medicines to the child at home? 12
Did you find the provider showed concern and empathy? 9
How confident do you feel in how much of the medication to give each day and how many days to give it? 9
If QR code scanning is not possible, please manually enter the participant identification code 9
How do you feel overall with the service you received at the facility today? 8
Would you recommend this facility to a friend / family with a sick child? 8
Did the provider speak in a language you understand? 7
Did you feel the provider treated you and the child with respect? 7
Did you find the provider was kind to you? 7
Was the service delayed or were you kept waiting for a long time? 7
What do you intend to do if the sick child does not get completely better or become worse? 6
Were you given general information or advice about feeding or breastfeeding? 5
Can you specify these signs and symptoms? 4
Were you informed of signs / symptoms that require you to bring the child back to the facility immediately? 4
Can you show me all the medicines and prescriptions that you received? 3
Did the provider use the device that is represented in the following picture during the consultation of the child? 3
Did the provider give or prescribe any medicines for the child to take home? 2
Did the provider refer the child? 2
Did the provider tell you what illness your child has? 2
Did the provider use a tablet like this one for the consultation of the child? 2
How did you feel with the fact that the provider used of a tablet for the consultation of the child? 2
Can you explain to me why this device was used? 1
Where will you look for treatment? 1